//package com.kunpan.admin.common.utils.file;
//
//import com.google.common.collect.Multimap;
//import io.minio.CreateMultipartUploadResponse;
//import io.minio.MinioAsyncClient;
//import io.minio.UploadPartResponse;
//import io.minio.errors.InsufficientDataException;
//import io.minio.errors.InternalException;
//import io.minio.errors.XmlParserException;
//
//import java.io.IOException;
//import java.security.InvalidKeyException;
//import java.security.NoSuchAlgorithmException;
//import java.util.concurrent.CompletableFuture;
//import java.util.concurrent.ExecutionException;
//
//public class MultipartMinioClient extends MinioAsyncClient {
//    protected MultipartMinioClient(MinioAsyncClient client) {
//        super(client);
//    }
//
//    /**
//     * 创建分片上传请求
//     *
//     * @param bucketName       存储桶
//     * @param region           区域
//     * @param objectName       对象名
//     * @param headers          消息头
//     * @param extraQueryParams 额外查询参数
//     */
//    public String multipartUpload(String bucket, String region, String object, Multimap<String, String> headers, Multimap<String, String> extraQueryParams)
//    {
//        CompletableFuture<CreateMultipartUploadResponse> response;
//        try {
//            response = this.createMultipartUploadAsync(bucket, region, object, headers, extraQueryParams);
//            return response.get().result().uploadId();
//        } catch (Exception e) {
//
//        }
//        return null;
//    }
//
//    public String multipartUpload(MultipartUploadCreateParam param)
//            throws InvalidKeyException, NoSuchAlgorithmException, InsufficientDataException, ServerException, InternalException, XmlParserException, InvalidResponseException, ErrorResponseException, IOException, InterruptedException, ExecutionException {
//        return this.multipartUpload(param.getBucketName(), param.getRegion(), param.getObjectName(), param.getHeaders(), param.getExtraQueryParams());
//    }
//
//    /**
//     * 分片上传
//     * @param bucketName Name of the bucket.
//     * @param region Region of the bucket (Optional).
//     * @param objectName Object name in the bucket.
//     * @param data Object data must be InputStream, RandomAccessFile, byte[] or String.
//     * @param length Length of object data.
//     * @param uploadId Upload ID.
//     * @param partNumber Part number.
//     * @param extraHeaders Extra headers for request (Optional).
//     * @param extraQueryParams Extra query parameters for request (Optional).
//     * @throws IOException
//     * @throws XmlParserException
//     * @throws NoSuchAlgorithmException
//     * @throws InternalException
//     * @throws InsufficientDataException
//     * @throws InvalidKeyException
//     */
//    public CompletableFuture<UploadPartResponse> uploadPartAsync(String bucketName, String region, String objectName, Object data,
//                                                                 long length, String uploadId, int partNumber, Multimap<String, String> extraHeaders, Multimap<String, String> extraQueryParams)
//            throws InvalidKeyException, InsufficientDataException, InternalException, NoSuchAlgorithmException, XmlParserException, IOException {
//        return super.uploadPartAsync(bucketName, region, objectName, data, length, uploadId, partNumber, extraHeaders, extraQueryParams);
//    }
//
//    public CompletableFuture<UploadPartResponse> uploadPartAsync(UploadPartCreateParam param)
//            throws InvalidKeyException, InsufficientDataException, InternalException, NoSuchAlgorithmException, XmlParserException, IOException{
//        return this.uploadPartAsync(param.getBucketName(), param.getRegion(), param.getObjectName(), param.getData(), param.getLength(),
//                param.getUploadId(), param.getPartNumber(),param.getHeaders(),
//                param.getExtraQueryParams());
//    }
//
//    /**
//     * 完成分片上传，执行合并文件
//     *
//     * @param bucketName       存储桶
//     * @param region           区域
//     * @param objectName       对象名
//     * @param uploadId         上传ID
//     * @param parts            分片
//     * @param extraHeaders     额外消息头
//     * @param extraQueryParams 额外查询参数
//     */
//    @Override
//    public CompletableFuture<ObjectWriteResponse> completeMultipartUploadAsync(String bucketName, String region, String objectName, String uploadId, Part[] parts, Multimap<String, String> extraHeaders, Multimap<String, String> extraQueryParams)
//            throws InsufficientDataException, InternalException, InvalidKeyException, IOException, NoSuchAlgorithmException, XmlParserException {
//        return super.completeMultipartUploadAsync(bucketName, region, objectName, uploadId, parts, extraHeaders, extraQueryParams);
//    }
//
//    public CompletableFuture<ObjectWriteResponse> completeMultipartUploadAsync(MultipartUploadCreateParam param)
//            throws InvalidKeyException, InsufficientDataException, InternalException, NoSuchAlgorithmException, XmlParserException, IOException{
//        return this.completeMultipartUploadAsync(param.getBucketName(), param.getRegion(), param.getObjectName(), param.getUploadId(), param.getParts(),
//                param.getHeaders(),param.getExtraQueryParams());
//    }
//
//    /**
//     * 查询分片数据
//     *
//     * @param bucketName       存储桶
//     * @param region           区域
//     * @param objectName       对象名
//     * @param uploadId         上传ID
//     * @param extraHeaders     额外消息头
//     * @param extraQueryParams 额外查询参数
//     */
//    @Override
//    public CompletableFuture<ListPartsResponse> listPartsAsync(String bucketName, String region, String objectName, Integer maxParts, Integer partNumberMarker, String uploadId, Multimap<String, String> extraHeaders, Multimap<String, String> extraQueryParams) throws InsufficientDataException, InternalException, InvalidKeyException, IOException, NoSuchAlgorithmException, XmlParserException {
//        return super.listPartsAsync(bucketName, region, objectName, maxParts, partNumberMarker, uploadId, extraHeaders, extraQueryParams);
//    }
//
//    public CompletableFuture<ListPartsResponse> listPartsAsync(MultipartUploadCreateParam param)
//            throws InvalidKeyException, InsufficientDataException, InternalException, NoSuchAlgorithmException, XmlParserException, IOException{
//        return this.listPartsAsync(param.getBucketName(), param.getRegion(), param.getObjectName(), param.getMaxParts(), param.getPartNumberMarker(),
//                param.getUploadId(), param.getHeaders(), param.getExtraQueryParams());
//    }
//}
